<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author: LJQ <245369209@qq.com> 
// +----------------------------------------------------------------------

namespace app\basic\model;
use app\common\model\Base;

/**
 * 员工管理
 */
class Staff extends Base{

	protected $name = "staff";
	protected $createTime = 'createTime';
	protected $updateTime = 'updateTime';
	
	public function getPostList(){
		$postList = db('basicinfo')->where(array('sysCode'=>8))->column('subsystemName','subsystemNo');
		return $postList;
		
	}
	
	public function getDepartmentList(){
		$departmentList = db('basicinfo')->where(array('sysCode'=>6))->column('subsystemName','subsystemNo');
		return $departmentList;
	}
	
	public function getPostAttr($value,$data){
		$postList = $this->getPostList();
		if($data['post']){
			return $postList[$data['post']];
		}
		return null;
	}
	
	public function getDepartmentIdAttr($value,$data){
		$departmentList = $this->getDepartmentList();
		if($data['departmentId']){
			return $departmentList[$data['departmentId']];
		}
		return null;
	}

	public function enterprise(){

	    return $this->hasOne('enterprise','id','enterpriseId');
	}
}